import {action} from 'mobx'
import {notification} from "antd";
import React from "react";

// 包含同步和异步的action
// 由于异步action有async前缀，所以同步异步的action很容易区分，所以没有对两种action分文件存放
export default class Actions {

    constructor(state) {
        this.state = state
    }
    @action.bound throwError({info, code, from}) {
        this.state.info = info
        this.state.code = code
        this.state.from = from
        this.state.date = new Date()
    }

    @action.bound errorInfo() {
        return notification.error({
            message: `error: ${this.state.info}`,
            description: (
                <div>
                    <p>{`code: [${this.state.code}]`}</p>
                    <p>{`from: [${this.state.from}]`}</p>
                </div>
            )
        })
    }
}